package com.stu.service.impl;

import com.github.pagehelper.Page;
import com.stu.bean.Images;
import com.stu.bean.ImagesExample;
import com.stu.mapper.ImagesMapper;
import com.stu.service.ImagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ImagesServiceImpl implements ImagesService {
    @Autowired
    private ImagesMapper imagesMapper;

    public Page<Images> selectImages(Images images) {
        return imagesMapper.selectImages(images);
    }

    public int deleteImages(int imgId) {
        return imagesMapper.deleteByPrimaryKey(imgId);
    }

    public Images insert(Images images) {
        Images img = null;
        int i = imagesMapper.insertSelective(images);
        if(i ==1){
            img = imagesMapper.selectImagesByUsername(images.getImgurl());
        }
        return img;
    }

    public int selectImgCount() {
        ImagesExample imagesExample=new ImagesExample();
        return imagesMapper.selectByExample(imagesExample).size();
    }
}
